package com.itheima.mapper;

import com.itheima.pojo.*;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;

@Mapper
public interface OrderDao {
    @Select("select * from t_order where id=#{id}")
    Order findById(Long id);
    @Select("select name from t_member where id=#{memberId}")
    String findMember(Integer memberId);
    @Select("select name from t_setmeal where id=#{setmealId}")
    Integer findSetmeal(Integer setmealId);
    @Select("select * from t_ordersetting where orderDate=#{orderDate}")
    OrderSetting findByDate(Date orderDate);

    @Select("select * from t_order inner join t_member where t_order.id=t_member.member_id and t_member.idCard=#{idCard}")
    Order findOrderByIdCard(String idCard);

    @Select("select * from t_member where idCard=#{idCard}")
    Member findByIdCard(String idCard);

    @Insert("insert into t_member(name,sex,idCard,phoneNumber,regTime)" +
            "values (#{name},#{sex},#{idCard},#{telephone},#{regDate})" )
    void insert(MemberVo memberVo);

    @Update("update t_ordersetting set reservations=reservations+1 where orderDate=#{orderDate}")
    void updateNum(Date orderDate);
}
